package com.alangeorge.web.bloodhound.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;

@SuppressWarnings("UnusedDeclaration")
@Entity
@Table(name = "geofence")
@NamedQueries({
        @NamedQuery(name="GeoFence.findByDeviceId", query = "select f from GeoFence f where :deviceId = :deviceId")
})
public class GeoFence {
    @Id // @Id indicates that this it a unique primary key
    @GeneratedValue(strategy = GenerationType.IDENTITY) // @GeneratedValue indicates that value is automatically generated by the server
    @Column(name = "id", unique = true, nullable = false)
    private long id;

    @Column(name = "device_id", length = 255, unique = false, nullable = false)
    private String deviceId;

    @Column(name = "latitude", unique = false, nullable = false)
    private float latitude;

    @Column(name = "longitude", unique = false, nullable = false)
    private float longitude;

    @Column(name = "radius", unique = false, nullable = false)
    private int radius;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "createtime", unique = false, nullable = false)
    private Date createTime;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "entertime", unique = false, nullable = true)
    private Date enterTime;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "dwelltime", unique = false, nullable = true)
    private Date dwellTime;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "exittime", unique = false, nullable = true)
    private Date exitTime;

    @Version
    private int version;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public float getLatitude() {
        return latitude;
    }

    public void setLatitude(float latitude) {
        this.latitude = latitude;
    }

    public float getLongitude() {
        return longitude;
    }

    public void setLongitude(float longitude) {
        this.longitude = longitude;
    }

    public long getRadius() {
        return radius;
    }

    public void setRadius(int radius) {
        this.radius = radius;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getEnterTime() {
        return enterTime;
    }

    public void setEnterTime(Date enterTime) {
        this.enterTime = enterTime;
    }

    public Date getDwellTime() {
        return dwellTime;
    }

    public void setDwellTime(Date dwellTime) {
        this.dwellTime = dwellTime;
    }

    public Date getExitTime() {
        return exitTime;
    }

    public void setExitTime(Date exitTime) {
        this.exitTime = exitTime;
    }

    public int getVersion() {
        return version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

    @Override
    public String toString() {
        return "GeoFence{" +
                "id=" + id +
                ", deviceId='" + deviceId + '\'' +
                ", latitude=" + latitude +
                ", longitude=" + longitude +
                ", radius=" + radius +
                ", createTime=" + createTime +
                ", enterTime=" + enterTime +
                ", dwellTime=" + dwellTime +
                ", exitTime=" + exitTime +
                ", version=" + version +
                '}';
    }
}
